var window  = {
    location    : {
        hash        : '',
        host        : 'weibo.com',
        hostname    : 'weibo.com',
        href        : 'http://weibo.com/',
        pathname    : '/',
        port        : '',
        protocol    : 'http:',
        search      : ''
    },
    navigator   : {
        appCodeName     : 'Mozilla',
        appName         : 'Netscape',
        appVersion      : '5.0 (Macintosh)',
        buildID         : '20120713134347',
        cookieEnabled   : true,
        doNotTrack      : 'unspecified',
        language        : 'en-US'
    }
};
var location    = window.location;
var navigator   = window.navigator;
/**
 * ssologin.js
 */
function SSOController() {
    var z;
    var C = this;
    var p = null;
    var g = 1800;
    var Z = 3600 * 24;
    var A = null;
    var K = null;
    var Q = 3;
    var H = null;
    var ab = "http://login.sina.com.cn/sso/crossdomain.php";
    var a = "http://login.sina.com.cn/sso/login.php";
    var x = "http://login.sina.com.cn/sso/logout.php";
    var P = "http://login.sina.com.cn/sso/updatetgt.php";
    var M = "http://login.sina.com.cn/sso/prelogin.php";
    var V = "http://login.sina.com.cn/bindmail/checkmailuser.php";
    var f = "http://login.sina.com.cn/cgi/pin.php";
    var W = "http://weibo.com/sguide/vdun.php";
    var E = null;
    var ag = "";
    var c = {};
    var I = "check_alt_login";
    var k = null;
    var L = null;
    var X = null;
    var ac = null;
    var af = 1;
    var w = 2;
    var ae = 4;
    var r = "";
    var R = {};
    var e = 0;
    var Y = 0;
    var U;
    this.https = 1;
    this.rsa = 2;
    this.wsse = 4;
    this.name = "sinaSSOController";
    this.loginFormId = "ssoLoginForm";
    this.scriptId = "ssoLoginScript";
    this.ssoCrossDomainScriptId = "ssoCrossDomainScriptId";
    this.loginFrameName = "ssoLoginFrame";
    this.appLoginURL = {"51uc.com": "http://passport.51uc.com/sso/login.php","weibo.com": "http://weibo.com/sso/login.php"};
    this.appDomainService = {"51uc.com": "51uc","weibo.com": "miniblog"};
    this.loginExtraQuery = {};
    this.setDomain = false;
    this.feedBackUrl = "";
    this.service = "sso";
    this.domain = "sina.com.cn";
    this.from = "";
    this.pageCharset = "GB2312";
    this.useTicket = false;
    this.isCheckLoginState = false;
    this.isUpdateCookieOnLoad = true;
    this.useIframe = true;
    this.noActiveTime = 7200;
    this.autoUpdateCookieTime = 1800;
    this.loginType = w;
    this.timeoutEnable = false;
    this.crossDomain = true;
    this.scriptLoginHttps = false;
    this.allowAutoFoundServerTime = false;
    this.allowAutoFoundServerTimeError = true;
    this.calcServerTimeInterval = 2000;
    this.servertime = null;
    this.nonce = null;
    this.rsaPubkey = null;
    this.rsakv = null;
    this.loginExtraFlag = {};
    this.cdult = false;
    this.crossDomainTime = 5;
    this.failRedirect = false;
    this.getVersion = function() {
        return "ssologin.js(v1.4.7) 2013-02-28"
    };
    this.getEntry = function() {
        return C.entry
    };
    this.getClientType = function() {
        return C.getVersion().split(" ")[0]
    };
    this.init = function() {
        if (F(arguments[0]) === "object") {
            return D(arguments[0])
        }
        C.setLoginType(C.loginType);
        var aj = window.sinaSSOConfig;
        if (typeof aj != "object") {
            aj = {}
        }
        var ai;
        for (ai in aj) {
            C[ai] = aj[ai]
        }
        if (!C.entry) {
            C.entry = C.service
        }
        if (C.isUpdateCookieOnLoad) {
            setTimeout(C.name + ".updateCookie()", 10000)
        }
        if (C.isCheckLoginState) {
            ah(window, "load", function() {
                C.checkLoginState()
            })
        }
        if (C.allowAutoFoundServerTime && ssoLoginServerTime) {
            C.setServerTime(ssoLoginServerTime)
        }
        C.customInit()
    };
    this.getLoginInfo = function() {
        return ad(h(l("sso_info")))
    };
    this.customInit = function() {
    };
    this.customUpdateCookieCallBack = function(ai) {
    };
    this.customLoginCallBack = function(ai) {
    };
    this.customLogoutCallBack = function(ai) {
        C.customLoginCallBack({result: false})
    };
    var N, D, O;
    (function() {
        var al = function() {
        }, aj = {username: "",password: "",savestate: 0,vsnf: 0,vsnval: "",door: "",setCookie: 0,cookieTimeout: 0,ssoSimpleLogin: 0,onComplete: al,onSuccess: al,onFailure: al}, an = {onComplete: al,onSuccess: al,onFailure: al}, ai = {vsnf: "vsnf",vsnval: "vsnval",door: "door",setCookie: "s",cookieTimeout: "ct",ssoSimpleLogin: "ssosimplelogin"}, am = {}, ao = {};
        var ak = function(at, aq) {
            var ar, au = {};
            at = at || {};
            aq = aq || {};
            m(au, at);
            for (ar in aq) {
                if (at.hasOwnProperty(ar)) {
                    au[ar] = aq[ar]
                }
            }
            return au
        };
        var ap = function(at, ar, aq) {
            if (typeof (at[ar]) === "function") {
                at[ar](aq)
            }
        };
        this.callbackLoginStatus = function(aq) {
            C.customLoginCallBack(aq);
            ap(am, "onComplete", aq);
            if (aq && aq.result === true) {
                ap(am, "onSuccess", aq)
            } else {
                ap(am, "onFailure", aq)
            }
        };
        U = function(aq) {
            C.customLogoutCallBack(aq);
            ap(ao, "onComplete", aq);
            if (aq && aq.result === true) {
                ap(ao, "onSuccess", aq)
            } else {
                ap(ao, "onFailure", aq)
            }
        };
        D = function(aq) {
            var ar;
            aq = aq || {};
            am = m({entry: "sso",useTicket: false,service: "sso",domain: "sina.com.cn",feedBackUrl: "",setDomain: false,crossDomain: true,name: "sinaSSOController"}, aj);
            am = ak(am, aq);
            window[am.name] = window[am.name] || C;
            for (ar in am) {
                if (!aj.hasOwnProperty(ar)) {
                    C[ar] = am[ar]
                }
            }
            C.loginExtraQuery = {};
            for (ar in ai) {
                if (am[ar]) {
                    C.loginExtraQuery[ai[ar]] = am[ar]
                }
            }
        };
        N = function(aq) {
            aq = aq || {};
            D(aq);
            C.login(am.username, am.password, am.savestate)
        };
        O = function(aq) {
            aq = aq || {};
            ao = m({}, an);
            ao = ak(ao, aq);
            C.logout()
        }
    }).apply(this);
    this.login = function(ak, ai, aj) {
        if (F(arguments[0]) === "object") {
            return N(arguments[0])
        }
        if (!L) {
            L = new S(C.timeoutEnable)
        } else {
            L.clear()
        }
        L.start(5000, function() {
            L.clear();
            C.callbackLoginStatus({result: false,reason: unescape("%u767B%u5F55%u8D85%u65F6%uFF0C%u8BF7%u91CD%u8BD5")})
        });
        aj = aj == z ? 0 : aj;
        R.savestate = aj;
        X = function() {
            if (C.useIframe && (C.setDomain || C.feedBackUrl)) {
                if (C.setDomain) {
                    document.domain = C.domain;
                    if (!C.feedBackUrl && C.domain != "sina.com.cn") {
                        C.feedBackUrl = i(C.appLoginURL[C.domain], {domain: 1})
                    }
                }
                ag = "post";
                var al = B(ak, ai, aj);
                if (!al) {
                    ag = "get";
                    if (C.scriptLoginHttps) {
                        C.setLoginType(C.loginType | af)
                    } else {
                        C.setLoginType(C.loginType | w)
                    }
                    u(ak, ai, aj)
                }
            } else {
                ag = "get";
                u(ak, ai, aj)
            }
            C.nonce = null
        };
        ac = function() {
            if ((C.loginType & ae) || (C.loginType & w)) {
                if (C.servertime) {
                    if (!C.nonce) {
                        C.nonce = J(6)
                    }
                    X();
                    return true
                }
                C.getServerTime(ak, X)
            } else {
                X()
            }
        };
        ac();
        return true
    };
    this.prelogin = function(ak, am) {
        var aj = location.protocol == "https:" ? M.replace(/^http:/, "https:") : M;
        var al = ak.username || "";
        al = sinaSSOEncoder.base64.encode(n(al));
        delete ak.username;
        var ai = {entry: C.entry,callback: C.name + ".preloginCallBack",su: al,rsakt: "mod"};
        aj = i(aj, m(ai, ak));
        C.preloginCallBack = function(an) {
            if (an && an.retcode == 0) {
                C.setServerTime(an.servertime);
                C.nonce = an.nonce;
                C.rsaPubkey = an.pubkey;
                C.rsakv = an.rsakv;
                r = an.pcid;
                Y = (new Date()).getTime() - e - (parseInt(an.exectime, 10) || 0)
            }
            if (typeof am == "function") {
                am(an)
            }
        };
        e = (new Date()).getTime();
        o(C.scriptId, aj)
    };
    this.getServerTime = function(aj, ai) {
        if (C.servertime) {
            if (typeof ai == "function") {
                ai({retcode: 0,servertime: C.servertime})
            }
            return true
        }
        C.prelogin({username: aj}, ai)
    };
    this.logout = function() {
        try {
            if (F(arguments[0]) === "object") {
                return O(arguments[0])
            }
            var aj = {entry: C.getEntry(),callback: C.name + ".ssoLogoutCallBack"};
            var ai = location.protocol == "https:" ? x.replace(/^http:/, "https:") : x;
            ai = i(ai, aj);
            o(C.scriptId, ai)
        } catch (ak) {
        }
        return true
    };
    this.ssoLogoutCallBack = function(ai) {
        if (ai.arrURL) {
            C.setCrossDomainUrlList(ai)
        }
        C.crossDomainAction("logout", function() {
            U({result: true})
        })
    };
    this.updateCookie = function() {
        try {
            if (C.autoUpdateCookieTime > 5) {
                if (p != null) {
                    clearTimeout(p)
                }
                p = setTimeout(C.name + ".updateCookie()", C.autoUpdateCookieTime * 1000)
            }
            var aj = C.getCookieExpireTime();
            var al = (new Date()).getTime() / 1000;
            var ai = {};
            if (aj == null) {
                ai = {retcode: 6102}
            } else {
                if (aj < al) {
                    ai = {retcode: 6203}
                } else {
                    if (aj - Z + g > al) {
                        ai = {retcode: 6110}
                    } else {
                        if (aj - al > C.noActiveTime) {
                            ai = {retcode: 6111}
                        }
                    }
                }
            }
            if (ai.retcode !== z) {
                C.customUpdateCookieCallBack(ai);
                return false
            }
            var ak = location.protocol == "https:" ? P.replace(/^http:/, "https:") : P;
            ak = i(ak, {entry: C.getEntry(),callback: C.name + ".updateCookieCallBack"});
            o(C.scriptId, ak)
        } catch (am) {
        }
        return true
    };
    this.setCrossDomainUrlList = function(ai) {
        E = ai
    };
    this.checkAltLoginNameCallback = function(aj) {
        var ai = {retcode: 0,detail: "",data: ""};
        if (aj.ret == "y") {
            ai.retcode = 1;
            ai.detail = '\u4e3a\u4e86\u60a8\u7684\u8d26\u53f7\u5b89\u5168\uff0c\u8bf7<a href="http://login.sina.com.cn/bindmail/signin.php?username=' + c.username + '">\u7ed1\u5b9a\u90ae\u7bb1</a>';
            ai.data = c.username
        } else {
            if (aj.ret == "n" && aj.mail) {
                if (aj.errcode == "not_verify") {
                    ai.retcode = 2;
                    ai.detail = "\u60a8\u7684\u90ae\u7bb1: " + aj.mail + ' \u672a\u9a8c\u8bc1\uff0c\u70b9\u6b64<a href="http://login.sina.com.cn/bindmail/bindmail1.php?entry=sso&user=' + aj.mail + '">\u91cd\u53d1\u9a8c\u8bc1\u90ae\u4ef6</a>';
                    ai.data = aj.mail
                } else {
                    ai.retcode = 3;
                    ai.detail = "\u7528\u60a8\u7684\u90ae\u7bb1" + aj.mail + "\u4e5f\u53ef\u4ee5\u767b\u5f55";
                    ai.data = aj.mail
                }
            } else {
            }
        }
        c.callback(ai)
    };
    this.checkAltLoginName = function(al, ak) {
        if (al == "") {
            return true
        }
        var aj = /^[0-9]{1,9}$/;
        if (aj.exec(al)) {
            return true
        }
        c = {username: al,callback: ak};
        var ai = (C.loginType & af) ? V.replace(/^http:/, "https:") : V;
        ai = i(ai, {name: al,type: "json",callback: C.name + ".checkAltLoginNameCallback"});
        o(I, ai)
    };
    this.callFeedBackUrl = function(ai) {
        try {
            var ak = {callback: C.name + ".feedBackUrlCallBack"};
            if (ai.ticket) {
                ak.ticket = ai.ticket
            }
            if (ai.retcode !== z) {
                ak.retcode = ai.retcode
            }
            var aj = i(C.feedBackUrl, ak);
            o(C.scriptId, aj)
        } catch (al) {
        }
        return true
    };
    this.loginCallBack = function(ai) {
        try {
            if (C.timeoutEnable && !L.isset()) {
                return
            }
            L.clear();
            C.loginExtraFlag = {};
            var aj = {};
            var ak = ai.ticket;
            var al = ai.uid;
            if (al) {
                aj.result = true;
                aj.retcode = 0;
                aj.userinfo = {uniqueid: ai.uid};
                if (ak) {
                    aj.ticket = ak
                }
                if (C.feedBackUrl) {
                    if (C.crossDomain) {
                        C.crossDomainAction("login", function() {
                            C.callFeedBackUrl(aj)
                        })
                    } else {
                        C.callFeedBackUrl(aj)
                    }
                } else {
                    if (C.crossDomain) {
                        if (ai.crossDomainUrlList) {
                            C.setCrossDomainUrlList({retcode: 0,arrURL: ai.crossDomainUrlList})
                        }
                        C.crossDomainAction("login", function() {
                            if (ak && C.appLoginURL[C.domain]) {
                                C.appLogin(ak, C.domain, C.name + ".callbackLoginStatus")
                            } else {
                                aj.userinfo = m(aj.userinfo, C.getSinaCookie());
                                C.callbackLoginStatus(aj)
                            }
                        })
                    } else {
                        C.callbackLoginStatus(aj)
                    }
                }
            } else {
                if (ac && ai.retcode == "2092" && C.allowAutoFoundServerTimeError) {
                    C.setServerTime(0);
                    C.loginExtraFlag = m(C.loginExtraFlag, {wsseretry: "servertime_error"});
                    ac();
                    ac = null;
                    return false
                }
                aj.result = false;
                aj.errno = ai.retcode;
                if (aj.errno == "4069") {
                    var an = ai.reason.split("|");
                    aj.reason = an[0];
                    if (an.length == 2) {
                        aj.rurl = an[1]
                    }
                    if (aj.rurl) {
                        try {
                            top.location.href = aj.rurl;
                            return
                        } catch (am) {
                        }
                    }
                } else {
                    aj.reason = ai.reason
                }
                C.callbackLoginStatus(aj)
            }
        } catch (am) {
        }
        return true
    };
    this.updateCookieCallBack = function(ai) {
        if (ai.retcode == 0) {
            C.crossDomainAction("update", function() {
                C.customUpdateCookieCallBack(ai)
            })
        } else {
            C.customUpdateCookieCallBack(ai)
        }
    };
    this.feedBackUrlCallBack = function(ai) {
        if (ag == "post" && C.timeoutEnable && !L.isset()) {
            return
        }
        L.clear();
        if (ai.errno == "2092") {
            C.setServerTime(0)
        }
        if (ai.errno == "4069") {
            var ak = ai.reason.split("|");
            ai.reason = ak[0];
            if (ak.length == 2) {
                ai.rurl = ak[1];
                try {
                    top.location.href = ai.rurl;
                    return
                } catch (aj) {
                }
            }
        }
        C.callbackLoginStatus(ai);
        t(C.loginFrameName)
    };
    this.doCrossDomainCallBack = function(ai) {
        C.crossDomainCounter++;
        if (ai) {
            t(ai.scriptId)
        }
        if (C.crossDomainCounter == C.crossDomainCount) {
            clearTimeout(K);
            C.crossDomainResult()
        }
    };
    this.crossDomainCallBack = function(ai) {
        t(C.ssoCrossDomainScriptId);
        if (!ai || ai.retcode != 0) {
            return false
        }
        var al = ai.arrURL;
        var aj, an;
        var am = {callback: C.name + ".doCrossDomainCallBack"};
        C.crossDomainCount = al.length;
        C.crossDomainCounter = 0;
        if (al.length == 0) {
            clearTimeout(K);
            C.crossDomainResult();
            return true
        }
        for (var ak = 0; ak < al.length; ak++) {
            aj = al[ak];
            an = "ssoscript" + ak;
            am.scriptId = an;
            aj = i(aj, am);
            if (j()) {
                y(an, aj)
            } else {
                o(an, aj)
            }
        }
    };
    this.crossDomainResult = function() {
        E = null;
        if (typeof A == "function") {
            A()
        }
    };
    this.crossDomainAction = function(al, am) {
        K = setTimeout(C.name + ".crossDomainResult()", Q * 1000);
        if (typeof am == "function") {
            A = am
        } else {
            A = null
        }
        if (E) {
            C.crossDomainCallBack(E);
            return false
        }
        var ak = C.domain;
        if (al == "update") {
            al = "login";
            ak = "sina.com.cn"
        }
        var aj = {scriptId: C.ssoCrossDomainScriptId,callback: C.name + ".crossDomainCallBack",action: al,domain: ak};
        var ai = i(ab, aj);
        o(C.ssoCrossDomainScriptId, ai)
    };
    this.checkLoginState = function(ai) {
        if (ai) {
            C.autoLogin(ai)
        } else {
            C.autoLogin(function(al) {
                var aj = {};
                if (al !== null) {
                    var ak = {displayname: al.nick,uniqueid: al.uid,userid: al.user};
                    aj.result = true;
                    aj.userinfo = ak
                } else {
                    aj.result = false;
                    aj.reason = ""
                }
                C.callbackLoginStatus(aj)
            })
        }
    };
    this.getCookieExpireTime = function() {
        return T(C.domain)
    };
    this.getSinaCookie = function(ai) {
        var aj = h(l("SUP"));
        if (!aj && !h(l("ALF"))) {
            return null
        }
        if (!aj) {
            aj = h(l("SUR"))
        }
        if (!aj) {
            return null
        }
        var ak = ad(aj);
        if (ai && ak.et && (ak.et * 1000 < (new Date()).getTime())) {
            return null
        }
        return ak
    };
    this.get51UCCookie = function() {
        return C.getSinaCookie()
    };
    this.autoLogin = function(aj, ai) {
        if (C.domain == "sina.com.cn") {
            if (l("SUP") === null && l("ALF") !== null) {
                s(aj);
                return true
            }
        } else {
            if (l("SUP") === null && (ai || l("SSOLoginState") !== null || l("ALF") !== null)) {
                s(aj);
                return true
            }
        }
        aj(C.getSinaCookie());
        return true
    };
    this.autoLoginCallBack2 = function(ai) {
        try {
            H(C.getSinaCookie())
        } catch (aj) {
        }
        return true
    };
    this.appLogin = function(ao, am, ap) {
        var al = R.savestate ? parseInt((new Date()).getTime() / 1000 + R.savestate * 86400) : 0;
        var ai = l("ALF") ? l("ALF") : 0;
        var ak = {callback: ap,ticket: ao,ssosavestate: al || ai};
        var an = C.appLoginURL[am];
        var aj = i(an, ak);
        o(C.scriptId, aj, "gb2312");
        return true
    };
    this.autoLoginCallBack3 = function(ai) {
        if (ai.retcode != 0) {
            C.autoLoginCallBack2(ai);
            return false
        }
        C.appLogin(ai.ticket, C.domain, C.name + ".autoLoginCallBack2");
        return true
    };
    this.setLoginType = function(aj) {
        var ai = location.protocol == "https:" ? C.https : 0;
        if (ai) {
            C.crossDomain = false
        }
        C.loginType = aj | ai;
        return true
    };
    this.setServerTime = function(aj) {
        if (!k) {
            k = new S(true)
        }
        if (aj == 0) {
            k.clear();
            C.servertime = aj;
            return true
        }
        if (aj < 1294935546) {
            return false
        }
        var ai = function() {
            if (C.servertime) {
                C.servertime += C.calcServerTimeInterval / 1000;
                k.start(C.calcServerTimeInterval, ai)
            }
        };
        C.servertime = aj;
        k.start(C.calcServerTimeInterval, ai)
    };
    this.getPinCodeUrl = function(aj) {
        if (aj == z) {
            aj = 0
        }
        if (r) {
            C.loginExtraQuery.pcid = r
        }
        var ai = location.protocol == "https:" ? f.replace(/^http:/, "https:") : f;
        return ai + "?r=" + Math.floor(Math.random() * 100000000) + "&s=" + aj + (r.length > 0 ? "&p=" + r : "")
    };
    this.showPinCode = function(ai) {
        C.$(ai).src = C.getPinCodeUrl()
    };
    this.isVfValid = function() {
        return C.getSinaCookie(true)["vf"] != 1
    };
    this.getVfValidUrl = function() {
        return W
    };
    this.enableFailRedirect = function() {
        C.failRedirect = true
    };
    var J = function(aj) {
        var ai = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        var al = "";
        for (var ak = 0; ak < aj; ak++) {
            al += ai.charAt(Math.ceil(Math.random() * 1000000) % ai.length)
        }
        return al
    };
    var s = function(ak) {
        H = ak;
        var aj = {entry: C.getEntry(),service: C.service,encoding: "UTF-8",gateway: 1,returntype: "TEXT",from: C.from};
        if (C.domain == "sina.com.cn") {
            aj.callback = C.name + ".autoLoginCallBack2";
            aj.useticket = 0
        } else {
            aj.callback = C.name + ".autoLoginCallBack3";
            aj.useticket = 1
        }
        var ai = location.protocol == "https:" ? a.replace(/^http:/, "https:") : a;
        ai = i(ai, aj);
        o(C.scriptId, ai, "gb2312");
        return true
    };
    var T = function(ak) {
        var aj = null;
        var ai = null;
        ai = C.getSinaCookie();
        if (ai) {
            aj = ai.et
        }
        return aj
    };
    var ah = function(ak, ai, aj) {
        if (ak.addEventListener) {
            ak.addEventListener(ai, aj, false)
        } else {
            if (ak.attachEvent) {
                ak.attachEvent("on" + ai, aj)
            } else {
                ak["on" + ai] = aj
            }
        }
    };
    var S = function(aj) {
        var ai = false;
        this.start = function(ak, al) {
            if (aj) {
                ai = setTimeout(al, ak)
            }
        };
        this.clear = function(ak) {
            if (aj) {
                clearTimeout(ai);
                ai = false
            }
        };
        this.isset = function() {
            return ai !== false
        }
    };
    var o = function(am, ak, al) {
        t(am);
        var aj = document.getElementsByTagName("head")[0];
        var ai = document.createElement("script");
        ai.charset = al || "gb2312";
        ai.id = am;
        ai.type = "text/javascript";
        ai.src = i(ak, {client: C.getClientType(),_: (new Date()).getTime()});
        aj.appendChild(ai)
    };
    var y = function(al, aj) {
        t(al);
        var ai = document.getElementsByTagName("body")[0];
        var ak = document.createElement("iframe");
        ak.style.display = "none";
        ak.src = i(aj, {client: C.getClientType(),_: (new Date()).getTime()});
        ak.isReady = false;
        ah(ak, "load", function() {
            if (ak.isReady) {
                return
            }
            ak.isReady = true;
            C.doCrossDomainCallBack({scriptId: al})
        });
        ai.appendChild(ak)
    };
    var v = function(am, aj, al) {
        var ak = {entry: C.getEntry(),gateway: 1,from: C.from,savestate: al,useticket: C.useTicket ? 1 : 0};
        if (C.failRedirect) {
            C.loginExtraQuery.frd = 1
        }
        ak = m(ak, {pagerefer: document.referrer || ""});
        ak = m(ak, C.loginExtraFlag);
        ak = m(ak, C.loginExtraQuery);
        ak.su = sinaSSOEncoder.base64.encode(n(am));
        if (C.service) {
            ak.service = C.service
        }
        if ((C.loginType & w) && C.servertime && sinaSSOEncoder && sinaSSOEncoder.RSAKey) {
            ak.servertime = C.servertime;
            ak.nonce = C.nonce;
            ak.pwencode = "rsa2";
            ak.rsakv = C.rsakv;
            var ai = new sinaSSOEncoder.RSAKey();
            ai.setPublic(C.rsaPubkey, "10001");
            aj = ai.encrypt([C.servertime, C.nonce].join("\t") + "\n" + aj)
        } else {
            if ((C.loginType & ae) && C.servertime && sinaSSOEncoder && sinaSSOEncoder.hex_sha1) {
                ak.servertime = C.servertime;
                ak.nonce = C.nonce;
                ak.pwencode = "wsse";
                aj = sinaSSOEncoder.hex_sha1("" + sinaSSOEncoder.hex_sha1(sinaSSOEncoder.hex_sha1(aj)) + C.servertime + C.nonce)
            }
        }
        ak.sp = aj;
        return ak
    };
    var u = function(an, ak, am) {
        if (C.appLoginURL[C.domain]) {
            C.useTicket = 1;
            C.service = C.appDomainService[C.domain] || C.service
        }
        var ai = 0;
        if (C.domain) {
            ai = 2
        }
        if (!C.appLoginURL[C.domain]) {
            ai = 3
        }
        if (C.cdult !== false) {
            ai = C.cdult
        }
        if (ai == 3) {
            Q = C.crossDomainTime;
            delete C.appLoginURL[C.domain]
        }
        var al = v(an, ak, am);
        al = m(al, {encoding: "UTF-8",callback: C.name + ".loginCallBack",cdult: ai,domain: C.domain,useticket: C.appLoginURL[C.domain] ? 1 : 0,prelt: Y,returntype: "TEXT"});
        var aj = (C.loginType & af) ? a.replace(/^http:/, "https:") : a;
        aj = i(aj, al);
        o(C.scriptId, aj, "gb2312")
    };
    var B = function(al, aq, am) {
        q(C.loginFrameName);
        var ao = b(C.loginFormId);
        var ak = v(al, aq, am);
        ak.encoding = "UTF-8";
        if (C.crossDomain == false) {
            ak.crossdomain = 0
        }
        ak.prelt = Y;
        if (C.feedBackUrl) {
            ak.url = i(C.feedBackUrl, {framelogin: 1,callback: "parent." + C.name + ".feedBackUrlCallBack"});
            ak.returntype = "META"
        } else {
            ak.callback = "parent." + C.name + ".loginCallBack";
            ak.returntype = "IFRAME";
            ak.setdomain = C.setDomain ? 1 : 0
        }
        for (var ap in C.loginExtraQuery) {
            if (typeof C.loginExtraQuery[ap] == "function") {
                continue
            }
            ak[ap] = C.loginExtraQuery[ap]
        }
        for (var ai in ak) {
            ao.addInput(ai, ak[ai])
        }
        var aj = (C.loginType & af) ? a.replace(/^http:/, "https:") : a;
        aj = i(aj, m({client: C.getClientType()}, C.loginExtraFlag));
        ao.method = "post";
        ao.action = aj;
        ao.target = C.loginFrameName;
        var ar = true;
        try {
            ao.submit()
        } catch (an) {
            t(C.loginFrameName);
            ar = false
        }
        setTimeout(function() {
            t(ao)
        }, 10);
        return ar
    };
    var q = function(ai, ak) {
        if (ak == null) {
            ak = "javascript:false;"
        }
        t(ai);
        var aj = document.createElement("iframe");
        aj.height = 0;
        aj.width = 0;
        aj.style.display = "none";
        aj.name = ai;
        aj.id = ai;
        aj.src = ak;
        d(document.body, aj);
        window.frames[ai].name = ai;
        return aj
    };
    var b = function(ai, ak) {
        if (ak == null) {
            ak = "none"
        }
        t(ai);
        var aj = document.createElement("form");
        aj.height = 0;
        aj.width = 0;
        aj.style.display = ak;
        aj.name = ai;
        aj.id = ai;
        d(document.body, aj);
        document.forms[ai].name = ai;
        aj.addInput = function(am, ao, an) {
            if (an == null) {
                an = "text"
            }
            var al = this.getElementsByTagName("input")[am];
            if (al) {
                this.removeChild(al)
            }
            al = document.createElement("input");
            this.appendChild(al);
            al.id = am;
            al.name = am;
            al.type = an;
            al.value = ao
        };
        return aj
    };
    var t = function(ai) {
        try {
            if (typeof (ai) === "string") {
                ai = C.$(ai)
            }
            ai.parentNode.removeChild(ai)
        } catch (aj) {
        }
    };
    var F = function(ai) {
        if (typeof (ai) === "undefined") {
            return "undefined"
        }
        if (ai === null) {
            return "null"
        }
        return Object.prototype.toString.call(ai).replace(/^\[object\s|\]$/gi, "").toLowerCase()
    };
    var j = function() {
        var ai = navigator.userAgent.toLowerCase();
        return ((/webkit/i).test(ai) && !(/chrome/i).test(ai))
    };
    var d = function(aj, ai) {
        aj.appendChild(ai)
    };
    var l = function(aj) {
        var ai = (new RegExp(aj + "=([^;]+)")).exec(document.cookie);
        return ai == null ? null : ai[1]
    };
    var i = function(ai, aj) {
        return ai + G(ai) + aa(aj)
    };
    var G = function(ai) {
        return (/\?/.test(ai) ? "&" : "?")
    };
    var n = function(ai) {
        return encodeURIComponent(ai)
    };
    var h = function(aj) {
        if (aj == null) {
            return ""
        } else {
            try {
                return decodeURIComponent(aj)
            } catch (ai) {
                return ""
            }
        }
    };
    var aa = function(ak) {
        if (typeof ak != "object") {
            return ""
        }
        var ai = new Array();
        for (var aj in ak) {
            if (typeof ak[aj] == "function") {
                continue
            }
            ai.push(aj + "=" + n(ak[aj]))
        }
        return ai.join("&")
    };
    var ad = function(am) {
        var ai = am.split("&");
        var al;
        var aj = {};
        for (var ak = 0; ak < ai.length; ak++) {
            al = ai[ak].split("=");
            aj[al[0]] = h(al[1])
        }
        return aj
    };
    var m = function(ak, aj) {
        for (var ai in aj) {
            ak[ai] = aj[ai]
        }
        return ak
    };
    this.$ = function(ai) {
        return document.getElementById(ai)
    }
}
var sinaSSOEncoder = sinaSSOEncoder || {};
(function() {
    var i = 0;
    var g = 8;
    this.hex_sha1 = function(j) {
        return h(b(f(j), j.length * g))
    };
    var b = function(A, r) {
        A[r >> 5] |= 128 << (24 - r % 32);
        A[((r + 64 >> 9) << 4) + 15] = r;
        var B = Array(80);
        var z = 1732584193;
        var y = -271733879;
        var v = -1732584194;
        var u = 271733878;
        var s = -1009589776;
        for (var o = 0; o < A.length; o += 16) {
            var q = z;
            var p = y;
            var n = v;
            var m = u;
            var k = s;
            for (var l = 0; l < 80; l++) {
                if (l < 16) {
                    B[l] = A[o + l]
                } else {
                    B[l] = d(B[l - 3] ^ B[l - 8] ^ B[l - 14] ^ B[l - 16], 1)
                }
                var C = e(e(d(z, 5), a(l, y, v, u)), e(e(s, B[l]), c(l)));
                s = u;
                u = v;
                v = d(y, 30);
                y = z;
                z = C
            }
            z = e(z, q);
            y = e(y, p);
            v = e(v, n);
            u = e(u, m);
            s = e(s, k)
        }
        return Array(z, y, v, u, s)
    };
    var a = function(k, j, m, l) {
        if (k < 20) {
            return (j & m) | ((~j) & l)
        }
        if (k < 40) {
            return j ^ m ^ l
        }
        if (k < 60) {
            return (j & m) | (j & l) | (m & l)
        }
        return j ^ m ^ l
    };
    var c = function(j) {
        return (j < 20) ? 1518500249 : (j < 40) ? 1859775393 : (j < 60) ? -1894007588 : -899497514
    };
    var e = function(j, m) {
        var l = (j & 65535) + (m & 65535);
        var k = (j >> 16) + (m >> 16) + (l >> 16);
        return (k << 16) | (l & 65535)
    };
    var d = function(j, k) {
        return (j << k) | (j >>> (32 - k))
    };
    var f = function(m) {
        var l = Array();
        var j = (1 << g) - 1;
        for (var k = 0; k < m.length * g; k += g) {
            l[k >> 5] |= (m.charCodeAt(k / g) & j) << (24 - k % 32)
        }
        return l
    };
    var h = function(l) {
        var k = i ? "0123456789ABCDEF" : "0123456789abcdef";
        var m = "";
        for (var j = 0; j < l.length * 4; j++) {
            m += k.charAt((l[j >> 2] >> ((3 - j % 4) * 8 + 4)) & 15) + k.charAt((l[j >> 2] >> ((3 - j % 4) * 8)) & 15)
        }
        return m
    };
    this.base64 = {encode: function(l) {
            l = "" + l;
            if (l == "") {
                return ""
            }
            var j = "";
            var s, q, o = "";
            var r, p, n, m = "";
            var k = 0;
            do {
                s = l.charCodeAt(k++);
                q = l.charCodeAt(k++);
                o = l.charCodeAt(k++);
                r = s >> 2;
                p = ((s & 3) << 4) | (q >> 4);
                n = ((q & 15) << 2) | (o >> 6);
                m = o & 63;
                if (isNaN(q)) {
                    n = m = 64
                } else {
                    if (isNaN(o)) {
                        m = 64
                    }
                }
                j = j + this._keys.charAt(r) + this._keys.charAt(p) + this._keys.charAt(n) + this._keys.charAt(m);
                s = q = o = "";
                r = p = n = m = ""
            } while (k < l.length);
            return j
        },_keys: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}
}).call(sinaSSOEncoder);
(function() {
    var av;
    var ah = 244837814094590;
    var Y = ((ah & 16777215) == 15715070);
    function aq(z, t, az) {
        if (z != null) {
            if ("number" == typeof z) {
                this.fromNumber(z, t, az)
            } else {
                if (t == null && "string" != typeof z) {
                    this.fromString(z, 256)
                } else {
                    this.fromString(z, t)
                }
            }
        }
    }
    function h() {
        return new aq(null)
    }
    function b(aB, t, z, aA, aD, aC) {
        while (--aC >= 0) {
            var az = t * this[aB++] + z[aA] + aD;
            aD = Math.floor(az / 67108864);
            z[aA++] = az & 67108863
        }
        return aD
    }
    function ax(aB, aG, aH, aA, aE, t) {
        var aD = aG & 32767, aF = aG >> 15;
        while (--t >= 0) {
            var az = this[aB] & 32767;
            var aC = this[aB++] >> 15;
            var z = aF * az + aC * aD;
            az = aD * az + ((z & 32767) << 15) + aH[aA] + (aE & 1073741823);
            aE = (az >>> 30) + (z >>> 15) + aF * aC + (aE >>> 30);
            aH[aA++] = az & 1073741823
        }
        return aE
    }
    function aw(aB, aG, aH, aA, aE, t) {
        var aD = aG & 16383, aF = aG >> 14;
        while (--t >= 0) {
            var az = this[aB] & 16383;
            var aC = this[aB++] >> 14;
            var z = aF * az + aC * aD;
            az = aD * az + ((z & 16383) << 14) + aH[aA] + aE;
            aE = (az >> 28) + (z >> 14) + aF * aC;
            aH[aA++] = az & 268435455
        }
        return aE
    }
    if (Y && (navigator.appName == "Microsoft Internet Explorer")) {
        aq.prototype.am = ax;
        av = 30
    } else {
        if (Y && (navigator.appName != "Netscape")) {
            aq.prototype.am = b;
            av = 26
        } else {
            aq.prototype.am = aw;
            av = 28
        }
    }
    aq.prototype.DB = av;
    aq.prototype.DM = ((1 << av) - 1);
    aq.prototype.DV = (1 << av);
    var Z = 52;
    aq.prototype.FV = Math.pow(2, Z);
    aq.prototype.F1 = Z - av;
    aq.prototype.F2 = 2 * av - Z;
    var ad = "0123456789abcdefghijklmnopqrstuvwxyz";
    var af = new Array();
    var ao, v;
    ao = "0".charCodeAt(0);
    for (v = 0; v <= 9; ++v) {
        af[ao++] = v
    }
    ao = "a".charCodeAt(0);
    for (v = 10; v < 36; ++v) {
        af[ao++] = v
    }
    ao = "A".charCodeAt(0);
    for (v = 10; v < 36; ++v) {
        af[ao++] = v
    }
    function ay(t) {
        return ad.charAt(t)
    }
    function A(z, t) {
        var az = af[z.charCodeAt(t)];
        return (az == null) ? -1 : az
    }
    function X(z) {
        for (var t = this.t - 1; t >= 0; --t) {
            z[t] = this[t]
        }
        z.t = this.t;
        z.s = this.s
    }
    function n(t) {
        this.t = 1;
        this.s = (t < 0) ? -1 : 0;
        if (t > 0) {
            this[0] = t
        } else {
            if (t < -1) {
                this[0] = t + DV
            } else {
                this.t = 0
            }
        }
    }
    function c(t) {
        var z = h();
        z.fromInt(t);
        return z
    }
    function w(aD, z) {
        var aA;
        if (z == 16) {
            aA = 4
        } else {
            if (z == 8) {
                aA = 3
            } else {
                if (z == 256) {
                    aA = 8
                } else {
                    if (z == 2) {
                        aA = 1
                    } else {
                        if (z == 32) {
                            aA = 5
                        } else {
                            if (z == 4) {
                                aA = 2
                            } else {
                                this.fromRadix(aD, z);
                                return
                            }
                        }
                    }
                }
            }
        }
        this.t = 0;
        this.s = 0;
        var aC = aD.length, az = false, aB = 0;
        while (--aC >= 0) {
            var t = (aA == 8) ? aD[aC] & 255 : A(aD, aC);
            if (t < 0) {
                if (aD.charAt(aC) == "-") {
                    az = true
                }
                continue
            }
            az = false;
            if (aB == 0) {
                this[this.t++] = t
            } else {
                if (aB + aA > this.DB) {
                    this[this.t - 1] |= (t & ((1 << (this.DB - aB)) - 1)) << aB;
                    this[this.t++] = (t >> (this.DB - aB))
                } else {
                    this[this.t - 1] |= t << aB
                }
            }
            aB += aA;
            if (aB >= this.DB) {
                aB -= this.DB
            }
        }
        if (aA == 8 && (aD[0] & 128) != 0) {
            this.s = -1;
            if (aB > 0) {
                this[this.t - 1] |= ((1 << (this.DB - aB)) - 1) << aB
            }
        }
        this.clamp();
        if (az) {
            aq.ZERO.subTo(this, this)
        }
    }
    function O() {
        var t = this.s & this.DM;
        while (this.t > 0 && this[this.t - 1] == t) {
            --this.t
        }
    }
    function q(z) {
        if (this.s < 0) {
            return "-" + this.negate().toString(z)
        }
        var az;
        if (z == 16) {
            az = 4
        } else {
            if (z == 8) {
                az = 3
            } else {
                if (z == 2) {
                    az = 1
                } else {
                    if (z == 32) {
                        az = 5
                    } else {
                        if (z == 4) {
                            az = 2
                        } else {
                            return this.toRadix(z)
                        }
                    }
                }
            }
        }
        var aB = (1 << az) - 1, aE, t = false, aC = "", aA = this.t;
        var aD = this.DB - (aA * this.DB) % az;
        if (aA-- > 0) {
            if (aD < this.DB && (aE = this[aA] >> aD) > 0) {
                t = true;
                aC = ay(aE)
            }
            while (aA >= 0) {
                if (aD < az) {
                    aE = (this[aA] & ((1 << aD) - 1)) << (az - aD);
                    aE |= this[--aA] >> (aD += this.DB - az)
                } else {
                    aE = (this[aA] >> (aD -= az)) & aB;
                    if (aD <= 0) {
                        aD += this.DB;
                        --aA
                    }
                }
                if (aE > 0) {
                    t = true
                }
                if (t) {
                    aC += ay(aE)
                }
            }
        }
        return t ? aC : "0"
    }
    function R() {
        var t = h();
        aq.ZERO.subTo(this, t);
        return t
    }
    function ak() {
        return (this.s < 0) ? this.negate() : this
    }
    function G(t) {
        var az = this.s - t.s;
        if (az != 0) {
            return az
        }
        var z = this.t;
        az = z - t.t;
        if (az != 0) {
            return az
        }
        while (--z >= 0) {
            if ((az = this[z] - t[z]) != 0) {
                return az
            }
        }
        return 0
    }
    function j(z) {
        var aA = 1, az;
        if ((az = z >>> 16) != 0) {
            z = az;
            aA += 16
        }
        if ((az = z >> 8) != 0) {
            z = az;
            aA += 8
        }
        if ((az = z >> 4) != 0) {
            z = az;
            aA += 4
        }
        if ((az = z >> 2) != 0) {
            z = az;
            aA += 2
        }
        if ((az = z >> 1) != 0) {
            z = az;
            aA += 1
        }
        return aA
    }
    function u() {
        if (this.t <= 0) {
            return 0
        }
        return this.DB * (this.t - 1) + j(this[this.t - 1] ^ (this.s & this.DM))
    }
    function ap(az, z) {
        var t;
        for (t = this.t - 1; t >= 0; --t) {
            z[t + az] = this[t]
        }
        for (t = az - 1; t >= 0; --t) {
            z[t] = 0
        }
        z.t = this.t + az;
        z.s = this.s
    }
    function W(az, z) {
        for (var t = az; t < this.t; ++t) {
            z[t - az] = this[t]
        }
        z.t = Math.max(this.t - az, 0);
        z.s = this.s
    }
    function s(aE, aA) {
        var z = aE % this.DB;
        var t = this.DB - z;
        var aC = (1 << t) - 1;
        var aB = Math.floor(aE / this.DB), aD = (this.s << z) & this.DM, az;
        for (az = this.t - 1; az >= 0; --az) {
            aA[az + aB + 1] = (this[az] >> t) | aD;
            aD = (this[az] & aC) << z
        }
        for (az = aB - 1; az >= 0; --az) {
            aA[az] = 0
        }
        aA[aB] = aD;
        aA.t = this.t + aB + 1;
        aA.s = this.s;
        aA.clamp()
    }
    function l(aD, aA) {
        aA.s = this.s;
        var aB = Math.floor(aD / this.DB);
        if (aB >= this.t) {
            aA.t = 0;
            return
        }
        var z = aD % this.DB;
        var t = this.DB - z;
        var aC = (1 << z) - 1;
        aA[0] = this[aB] >> z;
        for (var az = aB + 1; az < this.t; ++az) {
            aA[az - aB - 1] |= (this[az] & aC) << t;
            aA[az - aB] = this[az] >> z
        }
        if (z > 0) {
            aA[this.t - aB - 1] |= (this.s & aC) << t
        }
        aA.t = this.t - aB;
        aA.clamp()
    }
    function aa(z, aA) {
        var az = 0, aB = 0, t = Math.min(z.t, this.t);
        while (az < t) {
            aB += this[az] - z[az];
            aA[az++] = aB & this.DM;
            aB >>= this.DB
        }
        if (z.t < this.t) {
            aB -= z.s;
            while (az < this.t) {
                aB += this[az];
                aA[az++] = aB & this.DM;
                aB >>= this.DB
            }
            aB += this.s
        } else {
            aB += this.s;
            while (az < z.t) {
                aB -= z[az];
                aA[az++] = aB & this.DM;
                aB >>= this.DB
            }
            aB -= z.s
        }
        aA.s = (aB < 0) ? -1 : 0;
        if (aB < -1) {
            aA[az++] = this.DV + aB
        } else {
            if (aB > 0) {
                aA[az++] = aB
            }
        }
        aA.t = az;
        aA.clamp()
    }
    function D(z, aA) {
        var t = this.abs(), aB = z.abs();
        var az = t.t;
        aA.t = az + aB.t;
        while (--az >= 0) {
            aA[az] = 0
        }
        for (az = 0; az < aB.t; ++az) {
            aA[az + t.t] = t.am(0, aB[az], aA, az, 0, t.t)
        }
        aA.s = 0;
        aA.clamp();
        if (this.s != z.s) {
            aq.ZERO.subTo(aA, aA)
        }
    }
    function Q(az) {
        var t = this.abs();
        var z = az.t = 2 * t.t;
        while (--z >= 0) {
            az[z] = 0
        }
        for (z = 0; z < t.t - 1; ++z) {
            var aA = t.am(z, t[z], az, 2 * z, 0, 1);
            if ((az[z + t.t] += t.am(z + 1, 2 * t[z], az, 2 * z + 1, aA, t.t - z - 1)) >= t.DV) {
                az[z + t.t] -= t.DV;
                az[z + t.t + 1] = 1
            }
        }
        if (az.t > 0) {
            az[az.t - 1] += t.am(z, t[z], az, 2 * z, 0, 1)
        }
        az.s = 0;
        az.clamp()
    }
    function E(aH, aE, aD) {
        var aN = aH.abs();
        if (aN.t <= 0) {
            return
        }
        var aF = this.abs();
        if (aF.t < aN.t) {
            if (aE != null) {
                aE.fromInt(0)
            }
            if (aD != null) {
                this.copyTo(aD)
            }
            return
        }
        if (aD == null) {
            aD = h()
        }
        var aB = h(), z = this.s, aG = aH.s;
        var aM = this.DB - j(aN[aN.t - 1]);
        if (aM > 0) {
            aN.lShiftTo(aM, aB);
            aF.lShiftTo(aM, aD)
        } else {
            aN.copyTo(aB);
            aF.copyTo(aD)
        }
        var aJ = aB.t;
        var az = aB[aJ - 1];
        if (az == 0) {
            return
        }
        var aI = az * (1 << this.F1) + ((aJ > 1) ? aB[aJ - 2] >> this.F2 : 0);
        var aQ = this.FV / aI, aP = (1 << this.F1) / aI, aO = 1 << this.F2;
        var aL = aD.t, aK = aL - aJ, aC = (aE == null) ? h() : aE;
        aB.dlShiftTo(aK, aC);
        if (aD.compareTo(aC) >= 0) {
            aD[aD.t++] = 1;
            aD.subTo(aC, aD)
        }
        aq.ONE.dlShiftTo(aJ, aC);
        aC.subTo(aB, aB);
        while (aB.t < aJ) {
            aB[aB.t++] = 0
        }
        while (--aK >= 0) {
            var aA = (aD[--aL] == az) ? this.DM : Math.floor(aD[aL] * aQ + (aD[aL - 1] + aO) * aP);
            if ((aD[aL] += aB.am(0, aA, aD, aK, 0, aJ)) < aA) {
                aB.dlShiftTo(aK, aC);
                aD.subTo(aC, aD);
                while (aD[aL] < --aA) {
                    aD.subTo(aC, aD)
                }
            }
        }
        if (aE != null) {
            aD.drShiftTo(aJ, aE);
            if (z != aG) {
                aq.ZERO.subTo(aE, aE)
            }
        }
        aD.t = aJ;
        aD.clamp();
        if (aM > 0) {
            aD.rShiftTo(aM, aD)
        }
        if (z < 0) {
            aq.ZERO.subTo(aD, aD)
        }
    }
    function N(t) {
        var z = h();
        this.abs().divRemTo(t, null, z);
        if (this.s < 0 && z.compareTo(aq.ZERO) > 0) {
            t.subTo(z, z)
        }
        return z
    }
    function K(t) {
        this.m = t
    }
    function U(t) {
        if (t.s < 0 || t.compareTo(this.m) >= 0) {
            return t.mod(this.m)
        } else {
            return t
        }
    }
    function aj(t) {
        return t
    }
    function J(t) {
        t.divRemTo(this.m, null, t)
    }
    function H(t, az, z) {
        t.multiplyTo(az, z);
        this.reduce(z)
    }
    function at(t, z) {
        t.squareTo(z);
        this.reduce(z)
    }
    K.prototype.convert = U;
    K.prototype.revert = aj;
    K.prototype.reduce = J;
    K.prototype.mulTo = H;
    K.prototype.sqrTo = at;
    function B() {
        if (this.t < 1) {
            return 0
        }
        var t = this[0];
        if ((t & 1) == 0) {
            return 0
        }
        var z = t & 3;
        z = (z * (2 - (t & 15) * z)) & 15;
        z = (z * (2 - (t & 255) * z)) & 255;
        z = (z * (2 - (((t & 65535) * z) & 65535))) & 65535;
        z = (z * (2 - t * z % this.DV)) % this.DV;
        return (z > 0) ? this.DV - z : -z
    }
    function f(t) {
        this.m = t;
        this.mp = t.invDigit();
        this.mpl = this.mp & 32767;
        this.mph = this.mp >> 15;
        this.um = (1 << (t.DB - 15)) - 1;
        this.mt2 = 2 * t.t
    }
    function ai(t) {
        var z = h();
        t.abs().dlShiftTo(this.m.t, z);
        z.divRemTo(this.m, null, z);
        if (t.s < 0 && z.compareTo(aq.ZERO) > 0) {
            this.m.subTo(z, z)
        }
        return z
    }
    function ar(t) {
        var z = h();
        t.copyTo(z);
        this.reduce(z);
        return z
    }
    function P(t) {
        while (t.t <= this.mt2) {
            t[t.t++] = 0
        }
        for (var az = 0; az < this.m.t; ++az) {
            var z = t[az] & 32767;
            var aA = (z * this.mpl + (((z * this.mph + (t[az] >> 15) * this.mpl) & this.um) << 15)) & t.DM;
            z = az + this.m.t;
            t[z] += this.m.am(0, aA, t, az, 0, this.m.t);
            while (t[z] >= t.DV) {
                t[z] -= t.DV;
                t[++z]++
            }
        }
        t.clamp();
        t.drShiftTo(this.m.t, t);
        if (t.compareTo(this.m) >= 0) {
            t.subTo(this.m, t)
        }
    }
    function al(t, z) {
        t.squareTo(z);
        this.reduce(z)
    }
    function y(t, az, z) {
        t.multiplyTo(az, z);
        this.reduce(z)
    }
    f.prototype.convert = ai;
    f.prototype.revert = ar;
    f.prototype.reduce = P;
    f.prototype.mulTo = y;
    f.prototype.sqrTo = al;
    function i() {
        return ((this.t > 0) ? (this[0] & 1) : this.s) == 0
    }
    function x(aE, aF) {
        if (aE > 4294967295 || aE < 1) {
            return aq.ONE
        }
        var aD = h(), az = h(), aC = aF.convert(this), aB = j(aE) - 1;
        aC.copyTo(aD);
        while (--aB >= 0) {
            aF.sqrTo(aD, az);
            if ((aE & (1 << aB)) > 0) {
                aF.mulTo(az, aC, aD)
            } else {
                var aA = aD;
                aD = az;
                az = aA
            }
        }
        return aF.revert(aD)
    }
    function am(az, t) {
        var aA;
        if (az < 256 || t.isEven()) {
            aA = new K(t)
        } else {
            aA = new f(t)
        }
        return this.exp(az, aA)
    }
    aq.prototype.copyTo = X;
    aq.prototype.fromInt = n;
    aq.prototype.fromString = w;
    aq.prototype.clamp = O;
    aq.prototype.dlShiftTo = ap;
    aq.prototype.drShiftTo = W;
    aq.prototype.lShiftTo = s;
    aq.prototype.rShiftTo = l;
    aq.prototype.subTo = aa;
    aq.prototype.multiplyTo = D;
    aq.prototype.squareTo = Q;
    aq.prototype.divRemTo = E;
    aq.prototype.invDigit = B;
    aq.prototype.isEven = i;
    aq.prototype.exp = x;
    aq.prototype.toString = q;
    aq.prototype.negate = R;
    aq.prototype.abs = ak;
    aq.prototype.compareTo = G;
    aq.prototype.bitLength = u;
    aq.prototype.mod = N;
    aq.prototype.modPowInt = am;
    aq.ZERO = c(0);
    aq.ONE = c(1);
    function k() {
        this.i = 0;
        this.j = 0;
        this.S = new Array()
    }
    function e(aB) {
        var aA, z, az;
        for (aA = 0; aA < 256; ++aA) {
            this.S[aA] = aA
        }
        z = 0;
        for (aA = 0; aA < 256; ++aA) {
            z = (z + this.S[aA] + aB[aA % aB.length]) & 255;
            az = this.S[aA];
            this.S[aA] = this.S[z];
            this.S[z] = az
        }
        this.i = 0;
        this.j = 0
    }
    function a() {
        var z;
        this.i = (this.i + 1) & 255;
        this.j = (this.j + this.S[this.i]) & 255;
        z = this.S[this.i];
        this.S[this.i] = this.S[this.j];
        this.S[this.j] = z;
        return this.S[(z + this.S[this.i]) & 255]
    }
    k.prototype.init = e;
    k.prototype.next = a;
    function an() {
        return new k()
    }
    var M = 256;
    var m;
    var T;
    var ab;
    function d(t) {
        T[ab++] ^= t & 255;
        T[ab++] ^= (t >> 8) & 255;
        T[ab++] ^= (t >> 16) & 255;
        T[ab++] ^= (t >> 24) & 255;
        if (ab >= M) {
            ab -= M
        }
    }
    function S() {
        d(new Date().getTime())
    }
    if (T == null) {
        T = new Array();
        ab = 0;
        var I;
        if (navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto && typeof (window.crypto.random) === "function") {
            var F = window.crypto.random(32);
            for (I = 0; I < F.length; ++I) {
                T[ab++] = F.charCodeAt(I) & 255
            }
        }
        while (ab < M) {
            I = Math.floor(65536 * Math.random());
            T[ab++] = I >>> 8;
            T[ab++] = I & 255
        }
        ab = 0;
        S()
    }
    function C() {
        if (m == null) {
            S();
            m = an();
            m.init(T);
            for (ab = 0; ab < T.length; ++ab) {
                T[ab] = 0
            }
            ab = 0
        }
        return m.next()
    }
    function au(z) {
        var t;
        for (t = 0; t < z.length; ++t) {
            z[t] = C()
        }
    }
    function ac() {
    }
    ac.prototype.nextBytes = au;
    function g(z, t) {
        return new aq(z, t)
    }
    function ag(az, aA) {
        var t = "";
        var z = 0;
        while (z + aA < az.length) {
            t += az.substring(z, z + aA) + "\n";
            z += aA
        }
        return t + az.substring(z, az.length)
    }
    function r(t) {
        if (t < 16) {
            return "0" + t.toString(16)
        } else {
            return t.toString(16)
        }
    }
    function ae(aA, aD) {
        if (aD < aA.length + 11) {
            alert("Message too long for RSA");
            return null
        }
        var aC = new Array();
        var az = aA.length - 1;
        while (az >= 0 && aD > 0) {
            var aB = aA.charCodeAt(az--);
            if (aB < 128) {
                aC[--aD] = aB
            } else {
                if ((aB > 127) && (aB < 2048)) {
                    aC[--aD] = (aB & 63) | 128;
                    aC[--aD] = (aB >> 6) | 192
                } else {
                    aC[--aD] = (aB & 63) | 128;
                    aC[--aD] = ((aB >> 6) & 63) | 128;
                    aC[--aD] = (aB >> 12) | 224
                }
            }
        }
        aC[--aD] = 0;
        var z = new ac();
        var t = new Array();
        while (aD > 2) {
            t[0] = 0;
            while (t[0] == 0) {
                z.nextBytes(t)
            }
            aC[--aD] = t[0]
        }
        aC[--aD] = 2;
        aC[--aD] = 0;
        return new aq(aC)
    }
    function L() {
        this.n = null;
        this.e = 0;
        this.d = null;
        this.p = null;
        this.q = null;
        this.dmp1 = null;
        this.dmq1 = null;
        this.coeff = null
    }
    function o(z, t) {
        if (z != null && t != null && z.length > 0 && t.length > 0) {
            this.n = g(z, 16);
            this.e = parseInt(t, 16)
        } else {
            alert("Invalid RSA public key")
        }
    }
    function V(t) {
        return t.modPowInt(this.e, this.n)
    }
    function p(az) {
        var t = ae(az, (this.n.bitLength() + 7) >> 3);
        if (t == null) {
            return null
        }
        var aA = this.doPublic(t);
        if (aA == null) {
            return null
        }
        var z = aA.toString(16);
        if ((z.length & 1) == 0) {
            return z
        } else {
            return "0" + z
        }
    }
    L.prototype.doPublic = V;
    L.prototype.setPublic = o;
    L.prototype.encrypt = p;
    this.RSAKey = L
}).call(sinaSSOEncoder);
sinaSSOController = new SSOController();
sinaSSOController.init();
var argv    = process.argv.splice(2);

var pubkey      = argv[0],
    servertime  = argv[1],
    nonce       = argv[2],
    password    = argv[3];

var RSAKey = new sinaSSOEncoder.RSAKey();
RSAKey.setPublic(pubkey, '10001');
password = RSAKey.encrypt([servertime, nonce].join("\t") + "\n" + password);
console.log(password);
process.exit();